<template>
  <el-dialog title="业绩合同指标库" :visible.sync="visible" width="80%">
    <div class="mod-config">
      <basic-container>
        <div class="avue-crud">
          <el-radio-group
            v-model="tabType"
            @change="getDataList"
            style="margin-bottom: 10px"
          >
            <el-radio-button label="1">通用指标</el-radio-button>
            <el-radio-button label="2">个性指标</el-radio-button>
          </el-radio-group>
          <el-table
            :data="dataList"
            stripe
            tooltip-effect="light"
            @selection-change="handleSelectionChange"
          >
            <el-table-column
              type="selection"
              header-align="center"
              align="center"
            ></el-table-column>
            <el-table-column prop="normLx" label="指标类型"> </el-table-column>
            <el-table-column prop="normName" label="指标名称" show-overflow-tooltip>
            </el-table-column>
            <el-table-column prop="normDw" label="指标单位"> </el-table-column>
            <el-table-column prop="normGsname" label="计算公式">
            </el-table-column>
            <el-table-column
              prop="normSm"
              show-overflow-tooltip
              label="指标说明"
            >
            </el-table-column>
            <el-table-column prop="normPx" label="指标序号"> </el-table-column>
          </el-table>
        </div>
      </basic-container>
    </div>
    <span slot="footer" class="dialog-footer">
      <el-button type="primary" @click="$emit('submit',selections)">添 加</el-button>
      <el-button @click="$emit('cancel')">取 消</el-button>
    </span>
  </el-dialog>
</template>
<script>
import { getNormByTypeAndDeptId } from "@/api/hetongrenwu/hetongyeji/hetongzb";
import { mapGetters } from "vuex";
export default {
  data() {
    return {
      dataList: [],
      tabType: "2",
      selections: [],
    };
  },
  props: {
    visible: false,
  },
  computed: {
    ...mapGetters({
      userInfo: "userInfo",
    }),
  },
  components: {},
  created() {
    this.getDataList();
  },
  methods: {
    handleSelectionChange(val) {
      this.selections = val;
     //console.log(this.selections)
    },
    // 获取数据列表
    getDataList() {
      if (this.tabType == "1") {
        getNormByTypeAndDeptId({ normType: "htrw_zb", normFl: "ty" }).then(
          (response) => {
            this.dataList = response.data.data.data;
          }
        );
      } else {
        getNormByTypeAndDeptId({
          normType: "htrw_zb",
          normFl: "gx",
          deptId: this.userInfo.deptId,
        }).then((response) => {
          this.dataList = response.data.data.data;
        });
      }
    },
  },
};
</script>
